Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates redirect handling #76

Merged
merged 16 commits into from
Sep 24, 2012
Merged

Updates redirect handling #76

merged 16 commits into from
Sep 24, 2012

Conversation

plessbd
Copy link

@plessbd plessbd commented Feb 25, 2012

When doing a post and getting a redirect response superagent tries to do another post and errors as there is no data to write.

error is "first argument must be a string or buffer"

also tries to redirect using same method when this is forbidden according to the spec
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3) without user confirmation
tested against http://jigsaw.w3.org/HTTP/300/

@lancejpollard
Copy link

I am having this same issue and this pull request fixes it, please merge.

@plessbd
Copy link
Author

plessbd commented Apr 20, 2012

I would really like to see this merged.
Is there anything else that I need to do to get this merged?

@hunterloftis
Copy link
Contributor

Also getting errors on a 302 response, but getting:

Error: connect ECONNREFUSED
      at errnoException (net.js:670:11)
      at Object.afterConnect [as oncomplete] (net.js:661:19)

However, the connection is definitely not refused as the server logger registers the request.

this.url = url;
if(res.statusCode !== 303 && this._redirectData && this.method !== 'HEAD' && this.method !== 'GET' ){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is really long, i'd rather have something like var seeOther = 303 == res.statusCode;\n var idempotent = 'HEAD' == this.method || 'GET' == this.method etc then followed by conditional. Also add a space if (... like the rest of the source

@tj
Copy link
Contributor

tj commented Sep 11, 2012

needs a rebase but other than the style related stuff I'll merge, thanks!

@plessbd
Copy link
Author

plessbd commented Sep 21, 2012

I think I did what I needed to...not sure about the rebasing

@tj
Copy link
Contributor

tj commented Sep 21, 2012

just realized you dont have any tests for this new code

added tests for redirect with data and authorization
fixed variable name
@plessbd
Copy link
Author

plessbd commented Sep 22, 2012

Added tests. Thank you for having me do this. It helped me find a few issues and taught me a lot.

changed to send(this_data) rather than just setting the content type, just in case.
@tj tj merged this pull request into ladjs:master Sep 24, 2012
request
.post('http://localhost:3003/addmovie')
.send({ name: 'Methos' })
.redirectData(true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed this, we shouldn't ever do this I dont wan't to buffer data and this will not support streams etc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this patch should have been more focused, this is a completely separate thing, I just didn't read very well :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants